package com.ftwj.controller;

import com.ftwj.entity.SchoolPlaceInfo;
import com.ftwj.service.HomePageService;
import com.ftwj.service.SchoolPlaceService;
import com.ftwj.service.UserAppointmentInfoService;
import com.ftwj.vo.UserAppointmentVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/homepage")
public class HomePageController {
    @Autowired
    private HomePageService homePageService;
    @Autowired
    private UserAppointmentInfoService userAppointmentInfoService;

    //预约占比
    @GetMapping("/reservation-ratio")
    public ResponseEntity<List<SchoolPlaceInfo>> getReservationRatio() {
        List<SchoolPlaceInfo> reservationRatioList = homePageService.getReservationRatio();
        return ResponseEntity.ok(reservationRatioList);
    }

    /**
     * 获取近15天每个场所每天的预约人数统计
     * @return 预约统计信息列表
     */
    @GetMapping("/statistics")
    public ResponseEntity<List<Map<String, Object>>> getAppointmentStatisticsByPlaceAndDay() {
        List<Map<String, Object>> statistics = homePageService.countAppointmentsByPlaceAndDayInLast15Days();
        return new ResponseEntity<>(statistics, HttpStatus.OK);
    }
    //预约动态
    @GetMapping("/details")
    public List<UserAppointmentVO> getAppointmentDetails() {

        return homePageService.getAppointmentDetails();
    }
}
